const express = require('express')
const router = express.Router()
const db = require('../db/index')


router.route('/register')
    .post(async (req, res, next) => {
        const result = await db.register.post({ ...req.body })
        res.render('register', {
            data: JSON.stringify({
                ret: true,
                status: result.status,
                registerInfo: result.info
            })
        })
    })
    .get(async (req, res, next) => {
        const result = await db.register.get({ ...req.query })
        res.render('register', {
            data: JSON.stringify({
                ret: true,
                status: result.status,
                info: result.info
            })
        })
    })


module.exports = router